/*
 * Created on Jun 2, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.jjprojects.earutility;
import java.io.File;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.Date;

import javax.swing.JOptionPane;


/**
 * @author U678864
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class HtmlReportCreator
{
    private StringBuffer strbufHtmlReport;
    String strFirstFileNameForReport = null;
    String strSecondFileNameForReport = null;
    
    EARFilesComparingTool objEARFilesComparingTool = null;

    private boolean boolSimilarFiles = false;
    private boolean boolChangedFiles = false;
    private boolean boolMissingFiles = false;
    
    public HtmlReportCreator(EARFilesComparingTool objEARFilesComparingTool)
    {
        this.objEARFilesComparingTool = objEARFilesComparingTool;
    }
    
    public void generateHTMLReport(String strHtmlReportFile)
    {
        boolSimilarFiles = objEARFilesComparingTool.chkSimilarFiles.isSelected();
        boolChangedFiles = objEARFilesComparingTool.chkChangedFiles.isSelected();
        boolMissingFiles = objEARFilesComparingTool.chkMissingFiles.isSelected();
        
        String strCurrentRecord = null;
        strbufHtmlReport = new StringBuffer(10000);
        
        //Adding Header Part
        strbufHtmlReport.append("<html><head><title>EAR FILES COMPARE  DETAILS</title></head>");
        
        //Adding Body
        strbufHtmlReport.append("<body bgcolor='#F4FFF4'>");
        
        //Adding Main Heading
        strbufHtmlReport.append("<table bgcolor='#408080' width='100%' border='0' cellpadding='2' cellspacing='1'>");
        strbufHtmlReport.append("<tr bgcolor='#408080' align='center'>");
        strbufHtmlReport.append("<td width='1%' bgcolor='#408080'><font face='Times New Roman' color='#ffffff'><b><h1><u>EAR FILES COMPARE  DETAILS</font></td>");
        strbufHtmlReport.append("</tr></table>");
        
        //Adding Basic Body Content
        generateHtmlLinkMenu(1);
        generateBasicDetails();
        generateHtmlLinkMenu(2);
        generateAllFilesDetails();
        if(boolMissingFiles)
        {
            generateHtmlLinkMenu(3);
            generateMissingFileDetails();
        }
        
        if(boolChangedFiles)
        {
            generateHtmlLinkMenu(4);
            generateChangedFileDetails();
        }
        
        if(boolSimilarFiles)
        {
            generateHtmlLinkMenu(5);
            generateSimilarFileDetails();
        }
        
        try
        {
            File fileToSave = new File(strHtmlReportFile);
            FileOutputStream fi = new FileOutputStream(fileToSave);
            PrintWriter pw = new PrintWriter(fi);
            
            pw.println(strbufHtmlReport); 
            pw.flush();
            pw.close();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        
        int intDialogSelection = JOptionPane.showConfirmDialog(objEARFilesComparingTool.dlgReportSelection, 
                "The report is generated\nDo you want to open it now", "Open Html Report File", JOptionPane.YES_NO_OPTION);
        
        if(intDialogSelection == 0)
        {
            objEARFilesComparingTool.dlgReportSelection.setVisible(false);
            String cmd = "cmd /c start iexplore \""+ strHtmlReportFile + "\"";
            try
            {
                Runtime.getRuntime().exec(cmd);
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
        }
        
    }
    
    public void generateHtmlLinkMenu(int intSelectedIndex)
    {
        if(intSelectedIndex == 1)
        {
            strbufHtmlReport.append("<a name='basicdetails'/>");
            strbufHtmlReport.append("<table bgcolor='#77BBBB' width='100%' border='0' cellpadding='2' cellspacing='1'>");
            strbufHtmlReport.append("<tr bgcolor='#77BBBB' align='center'>");
            strbufHtmlReport.append("<td width='1%' bgcolor=''><font size = '2' color='#ffffff'>Basic Details</font></td>");
            strbufHtmlReport.append("<td width='1%' bgcolor='#93A685'>");
            strbufHtmlReport.append("<a title='View All File Details' href='#alldetails'><font size = '2' color='#ffffff'>All File Details</font></a>");
            strbufHtmlReport.append("</td>");
            if(boolMissingFiles)
            {
                strbufHtmlReport.append("<td width='1%' bgcolor='#93A685'>");
                strbufHtmlReport.append("<a title='View Missing File Details' href='#missedfiledetails'><font size = '2' color='#ffffff'>Missing File Details</font></a>");
                strbufHtmlReport.append("</td>");
            }
            if(boolChangedFiles)
            {
                strbufHtmlReport.append("<td width='1%' bgcolor='#93A685'>");
                strbufHtmlReport.append("<a title='View Changed File Details' href='#changedfiledetails'><font size = '2' color='#ffffff'>Changed File Details</font></a>");
                strbufHtmlReport.append("</td>");
            }
            if(boolSimilarFiles)
            {
                strbufHtmlReport.append("<td width='1%' bgcolor='#93A685'>");
                strbufHtmlReport.append("<a title='View Similar File Details' href='#similarfiledetails'><font size = '2' color='#ffffff'>Similar File Details</font></a>");
                strbufHtmlReport.append("</td>");
            }
            strbufHtmlReport.append("</tr></table>");
        }
        else if(intSelectedIndex == 2)
        {
            strbufHtmlReport.append("<a name='alldetails'/>");
            strbufHtmlReport.append("<table bgcolor='#77BBBB' width='100%' border='0' cellpadding='2' cellspacing='1'>");
            strbufHtmlReport.append("<tr bgcolor='#77BBBB' align='center'>");
            strbufHtmlReport.append("<td width='1%' bgcolor='#93A685'>");
            strbufHtmlReport.append("<a title='View Basic Details' href='#basicdetails'><font size = '2' color='#ffffff'>Basic Details</font></a>");
            strbufHtmlReport.append("</td>");
            strbufHtmlReport.append("<td width='1%' bgcolor=''><font size = '2' color='#ffffff'>All File Details</font></td>");
            if(boolMissingFiles)
            {
                strbufHtmlReport.append("<td width='1%' bgcolor='#93A685'>");
                strbufHtmlReport.append("<a title='View Missing File Details' href='#missedfiledetails'><font size = '2' color='#ffffff'>Missing File Details</font></a>");
                strbufHtmlReport.append("</td>");
            }
            if(boolChangedFiles)
            {
                strbufHtmlReport.append("<td width='1%' bgcolor='#93A685'>");
                strbufHtmlReport.append("<a title='View Changed File Details' href='#changedfiledetails'><font size = '2' color='#ffffff'>Changed File Details</font></a>");
                strbufHtmlReport.append("</td>");
            }
            if(boolSimilarFiles)
            {
                strbufHtmlReport.append("<td width='1%' bgcolor='#93A685'>");
                strbufHtmlReport.append("<a title='View Similar File Details' href='#similarfiledetails'><font size = '2' color='#ffffff'>Similar File Details</font></a>");
                strbufHtmlReport.append("</td>");
            }
            strbufHtmlReport.append("</tr></table>");
        }
        else if(intSelectedIndex == 3)
        {
            strbufHtmlReport.append("<a name='missedfiledetails'/>");
            strbufHtmlReport.append("<table bgcolor='#77BBBB' width='100%' border='0' cellpadding='2' cellspacing='1'>");
            strbufHtmlReport.append("<tr bgcolor='#77BBBB' align='center'>");
            strbufHtmlReport.append("<td width='1%' bgcolor='#93A685'>");
            strbufHtmlReport.append("<a title='View Basic Details' href='#basicdetails'><font size = '2' color='#ffffff'>Basic Details</font></a>");
            strbufHtmlReport.append("</td>");
            strbufHtmlReport.append("<td width='1%' bgcolor='#93A685'>");
            strbufHtmlReport.append("<a title='View All File Details' href='#alldetails'><font size = '2' color='#ffffff'>All File Details</font></a>");
            strbufHtmlReport.append("</td>");
            if(boolMissingFiles)
            {
                strbufHtmlReport.append("<td width='1%' bgcolor=''><font size = '2' color='#ffffff'>Missing File Details</font></td>");
            }
            if(boolChangedFiles)
            {
                strbufHtmlReport.append("<td width='1%' bgcolor='#93A685'>");
                strbufHtmlReport.append("<a title='View Changed File Details' href='#changedfiledetails'><font size = '2' color='#ffffff'>Changed File Details</font></a>");
                strbufHtmlReport.append("</td>");
            }
            if(boolSimilarFiles)
            {
                strbufHtmlReport.append("<td width='1%' bgcolor='#93A685'>");
                strbufHtmlReport.append("<a title='View Similar File Details' href='#similarfiledetails'><font size = '2' color='#ffffff'>Similar File Details</font></a>");
                strbufHtmlReport.append("</td>");
            }
            strbufHtmlReport.append("</tr></table>");
        }
        else if(intSelectedIndex == 4)
        {
            strbufHtmlReport.append("<a name='changedfiledetails'/>");
            strbufHtmlReport.append("<table bgcolor='#77BBBB' width='100%' border='0' cellpadding='2' cellspacing='1'>");
            strbufHtmlReport.append("<tr bgcolor='#77BBBB' align='center'>");
            strbufHtmlReport.append("<td width='1%' bgcolor='#93A685'>");
            strbufHtmlReport.append("<a title='View Basic Details' href='#basicdetails'><font size = '2' color='#ffffff'>Basic Details</font></a>");
            strbufHtmlReport.append("</td>");
            strbufHtmlReport.append("<td width='1%' bgcolor='#93A685'>");
            strbufHtmlReport.append("<a title='View All File Details' href='#alldetails'><font size = '2' color='#ffffff'>All File Details</font></a>");
            strbufHtmlReport.append("</td>");
            if(boolMissingFiles)
            {
                strbufHtmlReport.append("<td width='1%' bgcolor='#93A685'>");
                strbufHtmlReport.append("<a title='View Missing File Details' href='#missedfiledetails'><font size = '2' color='#ffffff'>Missing File Details</font></a>");
                strbufHtmlReport.append("</td>");
            }
            if(boolChangedFiles)
            {
                strbufHtmlReport.append("<td width='1%' bgcolor=''><font size = '2' color='#ffffff'>Changed File Details</font></td>");
            }
            if(boolSimilarFiles)
            {
                strbufHtmlReport.append("<td width='1%' bgcolor='#93A685'>");
                strbufHtmlReport.append("<a title='View Similar File Details' href='#similarfiledetails'><font size = '2' color='#ffffff'>Similar File Details</font></a>");
                strbufHtmlReport.append("</td>");
            }
            strbufHtmlReport.append("</tr></table>");
        }
        else if(intSelectedIndex == 5)
        {
            strbufHtmlReport.append("<a name='similarfiledetails'/>");
            strbufHtmlReport.append("<table bgcolor='#77BBBB' width='100%' border='0' cellpadding='2' cellspacing='1'>");
            strbufHtmlReport.append("<tr bgcolor='#77BBBB' align='center'>");
            strbufHtmlReport.append("<td width='1%' bgcolor='#93A685'>");
            strbufHtmlReport.append("<a title='View Basic Details' href='#basicdetails'><font size = '2' color='#ffffff'>Basic Details</font></a>");
            strbufHtmlReport.append("</td>");
            strbufHtmlReport.append("<td width='1%' bgcolor='#93A685'>");
            strbufHtmlReport.append("<a title='View All File Details' href='#alldetails'><font size = '2' color='#ffffff'>All File Details</font></a>");
            strbufHtmlReport.append("</td>");
            if(boolMissingFiles)
            {
                strbufHtmlReport.append("<td width='1%' bgcolor='#93A685'>");
                strbufHtmlReport.append("<a title='View Missing File Details' href='#missedfiledetails'><font size = '2' color='#ffffff'>Missing File Details</font></a>");
                strbufHtmlReport.append("</td>");
            }
            if(boolChangedFiles)
            {
                strbufHtmlReport.append("<td width='1%' bgcolor='#93A685'>");
                strbufHtmlReport.append("<a title='View Changed File Details' href='#changedfiledetails'><font size = '2' color='#ffffff'>Changed File Details</font></a>");
                strbufHtmlReport.append("</td>");
            }
            if(boolSimilarFiles)
            {
                strbufHtmlReport.append("<td width='1%' bgcolor=''><font size = '2' color='#ffffff'>Similar File Details</font></td>");
            }
            strbufHtmlReport.append("</tr></table>");
        }
        strbufHtmlReport.append("<br>");
    }
    
    public void generateBasicDetails()
    {
        objEARFilesComparingTool.intSimilarFileCount = 0;
        objEARFilesComparingTool.intModifiedFileCount = 0;
        objEARFilesComparingTool.intMissingFirstFileCount = 0;
        objEARFilesComparingTool.intMissingSecondFileCount = 0;
        //Getting the Basic Details
        int intSize = objEARFilesComparingTool.vecEqualityStatus.size();
        String strFileCompareStatus = null;
        for(int i=0;i<intSize;i++)
        {
            strFileCompareStatus = objEARFilesComparingTool.vecEqualityStatus.get(i).toString();
            
            if(strFileCompareStatus.equals("EQUAL"))
            {
                objEARFilesComparingTool.intSimilarFileCount++;
            }
            else if(strFileCompareStatus.equals("NOT EQUAL"))
            {
                objEARFilesComparingTool.intModifiedFileCount++;
            }
            else if(strFileCompareStatus.equals("FILE MISSING"))
            {
                String strStatusDetails = objEARFilesComparingTool.vecEqualityStatusDetails.get(i).toString();
                if(strStatusDetails.endsWith("First JAR file"))
                {
                    objEARFilesComparingTool.intMissingFirstFileCount++;
                }
                else if(strStatusDetails.endsWith("Second JAR file"))
                {
                    objEARFilesComparingTool.intMissingSecondFileCount++;
                }
            }
        }
        
        if(objEARFilesComparingTool.strFirstParentFileName.trim().length() == 0)
        {
            strFirstFileNameForReport = objEARFilesComparingTool.strGlobleFirstEARFileName;
        }
        else
        {
            int intFirstFileLastIndex = objEARFilesComparingTool.strGlobleFirstEARFileName.lastIndexOf("\\");
            String strOnlyCurrentFirstFileName = objEARFilesComparingTool.strGlobleFirstEARFileName.substring(intFirstFileLastIndex);
            if(!(objEARFilesComparingTool.strGlobleFirstEARFileName.endsWith(strOnlyCurrentFirstFileName)))
            {
                strFirstFileNameForReport = objEARFilesComparingTool.strFirstParentFileName + strOnlyCurrentFirstFileName;
            }
            else
            {
                strFirstFileNameForReport = objEARFilesComparingTool.strFirstParentFileName;
            }
        }
        if(objEARFilesComparingTool.strSecondParentFileName.trim().length() == 0)
        {
            strSecondFileNameForReport = objEARFilesComparingTool.strGlobleSecondEARFileName;
        }
        else
        {
            int intSecondFileLastIndex = objEARFilesComparingTool.strGlobleSecondEARFileName.lastIndexOf("\\");
            String strOnlyCurrentSecondFileName = objEARFilesComparingTool.strGlobleSecondEARFileName.substring(intSecondFileLastIndex);
            if(!(objEARFilesComparingTool.strGlobleSecondEARFileName.endsWith(strOnlyCurrentSecondFileName)))
            {
                strSecondFileNameForReport = objEARFilesComparingTool.strSecondParentFileName + strOnlyCurrentSecondFileName;
            }
            else
            {
                strSecondFileNameForReport = objEARFilesComparingTool.strSecondParentFileName;
            }
        }
        
        strbufHtmlReport.append("<table bgcolor='#77BBBB' width='100%' border='0' cellpadding='2' cellspacing='1'>");
        strbufHtmlReport.append("<tr bgcolor='#77BBBB' align='left'>");
        strbufHtmlReport.append("<td width='100%' bgcolor='#77BBBB' align='Center' colspan='2'><font face='Times New Roman' size = '3' color='#000000'><b>BASIC DETAILS</font></td>");
        strbufHtmlReport.append("</tr>");
        strbufHtmlReport.append("<tr>");
        strbufHtmlReport.append("<td width='50%' bgcolor='#EAFFD5'><font face='Times New Roman' size = '2' color='#000000'>Left File Name</font></td>");
        strbufHtmlReport.append("<td width='50%' bgcolor='#EAFFD5'><font face='Times New Roman' size = '2' color='#000000'>" + strFirstFileNameForReport + "</font></td>");
        strbufHtmlReport.append("</tr>");
        strbufHtmlReport.append("<tr>");
        strbufHtmlReport.append("<td width='1%' bgcolor='#EAFFD5'><font face='Times New Roman' size = '2' color='#000000'>Right File Name</font></td>");
        strbufHtmlReport.append("<td width='1%' bgcolor='#EAFFD5'><font face='Times New Roman' size = '2' color='#000000'>" + strSecondFileNameForReport + "</font></td>");
        strbufHtmlReport.append("</tr>");
        strbufHtmlReport.append("<tr>");
        strbufHtmlReport.append("<td width='1%' bgcolor='#EAFFD5'><font face='Times New Roman' size = '2' color='#000000'>Files removed from " + strFirstFileNameForReport + "</font></td>");
        strbufHtmlReport.append("<td width='1%' bgcolor='#EAFFD5'><font face='Times New Roman' size = '2' color='#000000'>" + objEARFilesComparingTool.intMissingFirstFileCount + "</font></td>");
        strbufHtmlReport.append("</tr>");
        strbufHtmlReport.append("<tr>");
        strbufHtmlReport.append("<td width='1%' bgcolor='#EAFFD5'><font face='Times New Roman' size = '2' color='#000000'>Files removed from " + strSecondFileNameForReport + "</font></td>");
        strbufHtmlReport.append("<td width='1%' bgcolor='#EAFFD5'><font face='Times New Roman' size = '2' color='#000000'>" + objEARFilesComparingTool.intMissingSecondFileCount + "</font></td>");
        strbufHtmlReport.append("</tr>");
        strbufHtmlReport.append("<tr>");
        strbufHtmlReport.append("<td width='1%' bgcolor='#EAFFD5'><font face='Times New Roman' size = '2' color='#000000'>Number of Files Modified</font></td>");
        strbufHtmlReport.append("<td width='1%' bgcolor='#EAFFD5'><font face='Times New Roman' size = '2' color='#000000'>" + objEARFilesComparingTool.intModifiedFileCount + "</font></td>");
        strbufHtmlReport.append("</tr>");
        strbufHtmlReport.append("<tr>");
        strbufHtmlReport.append("<td width='1%' bgcolor='#EAFFD5'><font face='Times New Roman' size = '2' color='#000000'>Number of Similar Files </font></td>");
        strbufHtmlReport.append("<td width='1%' bgcolor='#EAFFD5'><font face='Times New Roman' size = '2' color='#000000'>" + objEARFilesComparingTool.intSimilarFileCount + "</font></td>");
        strbufHtmlReport.append("</tr>");
        strbufHtmlReport.append("</table>");
        strbufHtmlReport.append("<br><hr color='BLACK' size=1><br>");
    }
    
    public void generateAllFilesDetails()
    {
        strbufHtmlReport.append("<table bgcolor='#408080' width='100%' border='0' cellpadding='2' cellspacing='1'>");
        strbufHtmlReport.append("<tr align='center'>");
        strbufHtmlReport.append("<td bgcolor='#77BBBB'><font face='Times New Roman' color='#003333'><b>No.</td>");
        strbufHtmlReport.append("<td bgcolor='#77BBBB'><font face='Times New Roman' color='#003333'><b>" + strFirstFileNameForReport + "</td>");
        strbufHtmlReport.append("<td bgcolor='#77BBBB'>.</td>");
        strbufHtmlReport.append("<td bgcolor='#77BBBB'><font face='Times New Roman' color='#003333'><b>" + strSecondFileNameForReport + "</td>");
        strbufHtmlReport.append("<td bgcolor='#77BBBB'><font face='Times New Roman' color='#003333'><b>Compare Details</td>");
        strbufHtmlReport.append("</tr>");
        
        //Code for Displaying all the details
        int intSize = objEARFilesComparingTool.vecFirstEARFilesContent.size();
        int intLineNumber = 1;
        String strFirstFileContent = null;
        String strFileCompareStatus = null;
        String strSecondFileContent = null;
        String strFileCompareDetails = null;
        String strFileCompareStatusCode = null;
        String strColorCode = null;
        for(int i=0;i<intSize;i++)
        {
            strFirstFileContent = objEARFilesComparingTool.vecFirstEARFilesContent.get(i).toString();
            strFileCompareStatus = objEARFilesComparingTool.vecEqualityStatus.get(i).toString();
            strSecondFileContent = objEARFilesComparingTool.vecSecondEARFilesContent.get(i).toString();
            strFileCompareDetails = objEARFilesComparingTool.vecEqualityStatusDetails.get(i).toString();
            
            if((intLineNumber % 2) == 0)
            {
                strColorCode = "#EAFFD5";
            }
            else
            {
                strColorCode = "#F4FFF4";
            }
            
            if(strFileCompareStatus.equals("EQUAL"))
            {
                objEARFilesComparingTool.intSimilarFileCount++;
                strFileCompareStatusCode = " = ";
                strbufHtmlReport.append("<tr>");
                strbufHtmlReport.append("<td align = 'Center' width='2%' bgcolor='" + strColorCode + "'><font face='Times New Roman' size = '2' color='#000000'>" + intLineNumber + "</td>");
                strbufHtmlReport.append("<td align = 'Left' width='30%' bgcolor='" + strColorCode + "'><font face='Times New Roman' size = '2' color='#000000'>" + strFirstFileContent + "</td>");
                strbufHtmlReport.append("<td align = 'Center' width='2%' bgcolor='" + strColorCode + "'><font face='Times New Roman' size = '2' color='#000000'>" + strFileCompareStatusCode + "</td>");
                strbufHtmlReport.append("<td align = 'Left' width='30%' bgcolor='" + strColorCode + "'><font face='Times New Roman' size = '2' color='#000000'>" + strSecondFileContent + "</td>");
                strbufHtmlReport.append("<td align = 'Left' width='30%' bgcolor='" + strColorCode + "'><font face='Times New Roman' size = '2' color='#000000'>" + strFileCompareDetails + "</td>");
                strbufHtmlReport.append("</tr>");
            }
            else if(strFileCompareStatus.equals("NOT EQUAL"))
            {
                objEARFilesComparingTool.intModifiedFileCount++;
                strFileCompareStatusCode = "<>"; 
                strbufHtmlReport.append("<tr>");
                strbufHtmlReport.append("<td align = 'Center' width='2%' bgcolor='" + strColorCode + "'><font face='Times New Roman' size = '2' color='#0000FF'>" + intLineNumber + "</td>");
                strbufHtmlReport.append("<td align = 'Left' width='30%' bgcolor='" + strColorCode + "'><font face='Times New Roman' size = '2' color='#0000FF'>" + strFirstFileContent + "</td>");
                strbufHtmlReport.append("<td align = 'Center' width='2%' bgcolor='" + strColorCode + "'><font face='Times New Roman' size = '2' color='#0000FF'>" + strFileCompareStatusCode + "</td>");
                strbufHtmlReport.append("<td align = 'Left' width='30%' bgcolor='" + strColorCode + "'><font face='Times New Roman' size = '2' color='#0000FF'>" + strSecondFileContent + "</td>");
                strbufHtmlReport.append("<td align = 'Left' width='30%' bgcolor='" + strColorCode + "'><font face='Times New Roman' size = '2' color='#0000FF'>" + strFileCompareDetails + "</td>");
                strbufHtmlReport.append("</tr>");
            }
            else if(strFileCompareStatus.equals("FILE MISSING"))
            {
                objEARFilesComparingTool.intMissingFirstFileCount++;
                strFileCompareStatusCode = " * ";
                strbufHtmlReport.append("<tr>");
                strbufHtmlReport.append("<td align = 'Center' width='2%' bgcolor='" + strColorCode + "'><font face='Times New Roman' size = '2' color='#FF0000'>" + intLineNumber + "</td>");
                strbufHtmlReport.append("<td align = 'Left' width='30%' bgcolor='" + strColorCode + "'><font face='Times New Roman' size = '2' color='#FF0000'>" + strFirstFileContent + "</td>");
                strbufHtmlReport.append("<td align = 'Center' width='2%' bgcolor='" + strColorCode + "'><font face='Times New Roman' size = '2' color='#FF0000'>" + strFileCompareStatusCode + "</td>");
                strbufHtmlReport.append("<td align = 'Left' width='30%' bgcolor='" + strColorCode + "'><font face='Times New Roman' size = '2' color='#FF0000'>" + strSecondFileContent + "</td>");
                strbufHtmlReport.append("<td align = 'Left' width='30%' bgcolor='" + strColorCode + "'><font face='Times New Roman' size = '2' color='#FF0000'>" + strFileCompareDetails + "</td>");
                strbufHtmlReport.append("</tr>");
            }
            intLineNumber++;
        }
      
        strbufHtmlReport.append("</table>");
        strbufHtmlReport.append("<br><hr color='BLACK' size=1><br>");
    }
    
    public void generateMissingFileDetails()
    {
        strbufHtmlReport.append("<table bgcolor='#408080' width='100%' border='0' cellpadding='2' cellspacing='1'>");
        strbufHtmlReport.append("<tr align='center'>");
        strbufHtmlReport.append("<td bgcolor='#77BBBB'><font face='Times New Roman' color='#003333'><b>No.</td>");
        strbufHtmlReport.append("<td bgcolor='#77BBBB'><font face='Times New Roman' color='#003333'><b>File Missing in " + strFirstFileNameForReport + "</td>");
        strbufHtmlReport.append("</tr>");
        
        int intSize = objEARFilesComparingTool.vecSecondEARFilesContent.size();
        int intLineNumber = 1;
        String strFileContent = null;
        String strFileCompareStatus = null;
        String strColorCode = null;
        for(int i=0;i<intSize;i++)
        {
            strFileContent = objEARFilesComparingTool.vecSecondEARFilesContent.get(i).toString();
            if(strFileContent.trim().length() == 0)
            {
                continue;
            }
            strFileCompareStatus = objEARFilesComparingTool.vecEqualityStatus.get(i).toString();
            
            if(strFileCompareStatus.equals("FILE MISSING"))
            {
                if((intLineNumber % 2) == 0)
                {
                    strColorCode = "#EAFFD5";
                }
                else
                {
                    strColorCode = "#F4FFF4";
                }
                
                strbufHtmlReport.append("<tr>");
                strbufHtmlReport.append("<td align = 'Center' width='2%' bgcolor='" + strColorCode + "'><font face='Times New Roman' size = '2' color='#000000'>" + intLineNumber + "</td>");
                strbufHtmlReport.append("<td align = 'Left' width='30%' bgcolor='" + strColorCode + "'><font face='Times New Roman' size = '2' color='#000000'>" + strFileContent + "</td>");
                strbufHtmlReport.append("</tr>");
                intLineNumber++;
            }                
        }
        
        strbufHtmlReport.append("</table>");
        
        strbufHtmlReport.append("<br>");
        
        strbufHtmlReport.append("<table bgcolor='#408080' width='100%' border='0' cellpadding='2' cellspacing='1'>");
        strbufHtmlReport.append("<tr align='center'>");
        strbufHtmlReport.append("<td bgcolor='#77BBBB'><font face='Times New Roman' color='#003333'><b>No.</td>");
        strbufHtmlReport.append("<td bgcolor='#77BBBB'><font face='Times New Roman' color='#003333'><b>File Missing in " + strSecondFileNameForReport + "</td>");
        strbufHtmlReport.append("</tr>");

        intSize = objEARFilesComparingTool.vecFirstEARFilesContent.size();
        intLineNumber = 1;
        strFileContent = null;
        strFileCompareStatus = null;
        for(int i=0;i<intSize;i++)
        {
            strFileContent = objEARFilesComparingTool.vecFirstEARFilesContent.get(i).toString();
            if(strFileContent.trim().length() == 0)
            {
                continue;
            }
            strFileCompareStatus = objEARFilesComparingTool.vecEqualityStatus.get(i).toString();
            
            if(strFileCompareStatus.equals("FILE MISSING"))
            {
                if((intLineNumber % 2) == 0)
                {
                    strColorCode = "#EAFFD5";
                }
                else
                {
                    strColorCode = "#F4FFF4";
                }
                strbufHtmlReport.append("<tr>");
                strbufHtmlReport.append("<td align = 'Center' width='2%' bgcolor='" + strColorCode + "'><font face='Times New Roman' size = '2' color='#000000'>" + intLineNumber + "</td>");
                strbufHtmlReport.append("<td align = 'Left' width='30%' bgcolor='" + strColorCode + "'><font face='Times New Roman' size = '2' color='#000000'>" + strFileContent + "</td>");
                strbufHtmlReport.append("</tr>");
                intLineNumber++;
            }                
        }
               
        strbufHtmlReport.append("</table>");
        strbufHtmlReport.append("<br><hr color='BLACK' size=1><br>");
    }
    
    public void generateChangedFileDetails()
    {
        strbufHtmlReport.append("<table bgcolor='#408080' width='100%' border='0' cellpadding='2' cellspacing='1'>");
        strbufHtmlReport.append("<tr align='center'>");
        strbufHtmlReport.append("<td bgcolor='#77BBBB'><font face='Times New Roman' color='#003333'><b>No.</td>");
        strbufHtmlReport.append("<td bgcolor='#77BBBB'><font face='Times New Roman' color='#003333'><b>Changed File Name</td>");
        strbufHtmlReport.append("<td bgcolor='#77BBBB'><font face='Times New Roman' color='#003333'><b>File Change Details</td>");
        strbufHtmlReport.append("</tr>");
        
        int intSize = objEARFilesComparingTool.vecFirstEARFilesContent.size();
        int intLineNumber = 1;
        String strEARFileContent = null;
        String strEARFileCompareStatus = null;
        StringBuffer strbufEARCompareDetails = new StringBuffer(100);
        String strFirstEarFileSize = null;
        Date dateFirstEARFilesLastModifiedDate = null;
        String strSecondEarFileSize = null;
        Date dateSecondEARFilesLastModifiedDate = null; 
        String strSecondEARFikeModifiedDate = null;
        long longFirstEARFikeModifiedDate = 0;
        long longSecondEARFikeModifiedDate = 0;
        String strColorCode = null;
            
        for(int i=0;i<intSize;i++)
        {
            strEARFileCompareStatus = objEARFilesComparingTool.vecEqualityStatus.get(i).toString();
            
            if(strEARFileCompareStatus.equals("NOT EQUAL"))
            {
                if((intLineNumber % 2) == 0)
                {
                    strColorCode = "#EAFFD5";
                }
                else
                {
                    strColorCode = "#F4FFF4";
                }
                strEARFileContent = objEARFilesComparingTool.vecFirstEARFilesContent.get(i).toString();
                strFirstEarFileSize = objEARFilesComparingTool.vecFirstEARFilesSize.get(i).toString();
                String strFirstEARFikeModifiedDate = objEARFilesComparingTool.vecFirstEARFilesLastModifiedDate.get(i).toString();
                longFirstEARFikeModifiedDate = Long.parseLong(strFirstEARFikeModifiedDate);
                dateFirstEARFilesLastModifiedDate = new Date(longFirstEARFikeModifiedDate);
                strSecondEarFileSize = objEARFilesComparingTool.vecSecondEARFilesSize.get(i).toString();
                
                strSecondEARFikeModifiedDate = objEARFilesComparingTool.vecSecondEARFilesLastModifiedDate.get(i).toString();
                longSecondEARFikeModifiedDate = Long.parseLong(strSecondEARFikeModifiedDate);
                dateSecondEARFilesLastModifiedDate = new Date(longSecondEARFikeModifiedDate);
                
                strbufEARCompareDetails.append("The size of the file in ")
                    .append(strFirstFileNameForReport)
                    .append(" is ").append(strFirstEarFileSize)
                    .append(" and last modified on ").append(dateFirstEARFilesLastModifiedDate + "<br>");
                
                strbufEARCompareDetails.append("The size of the file in ")
                    .append(strSecondFileNameForReport)
                    .append(" is ").append(strSecondEarFileSize)
                    .append(" and last modified on ").append(dateSecondEARFilesLastModifiedDate + "<br>");
                
                strbufHtmlReport.append("<tr>");
                strbufHtmlReport.append("<td align = 'Center' width='2%' bgcolor='" + strColorCode + "'><font face='Times New Roman' size = '2' color='#000000'>" + intLineNumber + "</td>");
                strbufHtmlReport.append("<td align = 'Left' width='45%' bgcolor='" + strColorCode + "'><font face='Times New Roman' size = '2' color='#000000'>" + strEARFileContent + "</td>");
                strbufHtmlReport.append("<td align = 'Left' width='53%' bgcolor='" + strColorCode + "'><font face='Times New Roman' size = '2' color='#000000'>" + strbufEARCompareDetails.toString() + "</td>");
                strbufHtmlReport.append("</tr>");
                
                intLineNumber++;
                strbufEARCompareDetails.delete(0, strbufEARCompareDetails.length());
            }         
        }
        
        strbufHtmlReport.append("</table>");
        strbufHtmlReport.append("<br><hr color='BLACK' size=1><br>");
    }
    
    public void generateSimilarFileDetails()
    {
        strbufHtmlReport.append("<table bgcolor='#408080' width='100%' border='0' cellpadding='2' cellspacing='1'>");
        strbufHtmlReport.append("<tr align='center'>");
        strbufHtmlReport.append("<td bgcolor='#77BBBB'><font face='Times New Roman' color='#003333'><b>No.</td>");
        strbufHtmlReport.append("<td bgcolor='#77BBBB'><font face='Times New Roman' color='#003333'><b>Similar File Name</td>");
        strbufHtmlReport.append("</tr>");
        
        int intSize = objEARFilesComparingTool.vecFirstEARFilesContent.size();
        int intLineNumber = 1;
        String strEARFileContent = null;
        String strEARFileCompareStatus = null;
        String strColorCode = null;
        for(int i=0;i<intSize;i++)
        {
            strEARFileCompareStatus = objEARFilesComparingTool.vecEqualityStatus.get(i).toString();
            
            if(strEARFileCompareStatus.equals("EQUAL"))
            {
                if((intLineNumber % 2) == 0)
                {
                    strColorCode = "#EAFFD5";
                }
                else
                {
                    strColorCode = "#F4FFF4";
                }
                strEARFileContent = objEARFilesComparingTool.vecFirstEARFilesContent.get(i).toString();
                
                strbufHtmlReport.append("<tr>");
                strbufHtmlReport.append("<td align = 'Center'width='2%' bgcolor='" + strColorCode + "'><font face='Times New Roman' size = '2' color='#000000'>" + intLineNumber + "</td>");
                strbufHtmlReport.append("<td align = 'Left' width='98%' bgcolor='" + strColorCode + "'><font face='Times New Roman' size = '2' color='#000000'>" + strEARFileContent + "</td>");
                strbufHtmlReport.append("</tr>");
                
                intLineNumber++;
            }         
        }
        strbufHtmlReport.append("</table>");
        strbufHtmlReport.append("<br><hr color='BLACK' size=1><br>");
    }
}